package day8;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        //BufferedReader 从字符流中读取文本并且缓存
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bi.readLine());
        String[] str = new String[n];
        for(int i = 0; i < n; i++) {
            str[i] = bi.readLine();
        }
        //判断
        if(isLenSort(str) && isDiSort(str)) {
                System.out.println("both");
            }else if(isLenSort(str)) {
                System.out.println("lengths");
            }else if(isDiSort(str)) {
                System.out.println("lexicographically");
            }else {
                System.out.println("none");
            }

    }
    public static boolean isDiSort(String[] str) {
        for(int i = 0; i < str.length-1; i++) {
            //用当前的字符串和后一个字符串比较，如果字典序大于后一个，则返回false;
            if(str[i].compareTo(str[i+1]) > 0) {
                return false;
            }
        }
        return true;
    }
    public static boolean isLenSort(String[] str) {
        for(int i = 0; i < str.length-1; i++) {
            //如果当前字符串长度大于后一个字符串长度，那么返回false
            if(str[i].length() > str[i+1].length()) {
                return false;
            }
        }
        return true;
    }
}